﻿@model vITs.Site.Models.ActionModels.AddExpenseModel
@{
    this.ViewBag.Title = "Lägg till utgift";
}
@using (this.Html.BeginForm())
{
    <fieldset>
        <legend>
            <h2>Lägg till utgift</h2>
        </legend>
        <p>
            <b>Uppdrag:</b> @this.ViewBag.Assignment.AssignmentName
        </p>
        <input type="hidden" value="@this.ViewBag.Assignment.AssignmentId" name="AssignmentId" />
        @this.Html.ValidationSummary(true)
        <br />
        @this.Html.LabelFor(m => m.Name)
        <br />
        @this.Html.EditorFor(m => m.Name) @this.Html.ValidationMessageFor(m => m.Name)
        <br />
        @this.Html.LabelFor(m => m.Date)
        <br />
        @this.Html.EditorFor(m => m.Date) @this.Html.ValidationMessageFor(m => m.Date)
        <br />
        @this.Html.LabelFor(m => m.Sum)
        <br />
        @this.Html.EditorFor(m => m.Sum) @this.Html.ValidationMessageFor(m => m.Sum)
        <br />
        <input type="checkbox" onclick="javascript:toggleTaxInput();" /><label for="receipt">Kvitto Finns</label>
        <div id="taxInput" style="display:none;">
            @this.Html.LabelFor(m => m.Tax)
            <br />
            @this.Html.EditorFor(m => m.Tax) @this.Html.ValidationMessageFor(m => m.Tax)
        </div>
        <br />
        @this.Html.LabelFor(m => m.Currency)
        <br />
        @this.Html.EditorFor(m => m.Currency)
        <br />
        @this.Html.LabelFor(m => m.ExchangeRate)
        <br />
        @this.Html.EditorFor(m => m.ExchangeRate)
        <br />
        <input type="submit" value="Lägg till" />
    </fieldset>
}
<script src="../../Scripts/jquery-ui-1.8.11.min.js" type="text/javascript"></script>
<link href="../../Content/themes/base/jquery.ui.all.css" media="all" rel="stylesheet" type="text/css" />
<script type="text/javascript">
    $("#Date").datepicker();

    function toggleTaxInput() {
        $("#taxInput").toggle();
    }

    var tax = document.getElementById("Tax");
    if (tax.value == "") {
        tax.value = "0";
    }else {
        toggleTaxInput();
    }

    var currency = document.getElementById("Currency");
    if (currency.value == "") currency.value = 'SEK';
    var rate = document.getElementById("ExchangeRate");
    if (rate.value == "") rate.value = '1';

</script>
